package com.example.admin.controller;


import com.example.admin.common.Result;
import com.example.admin.entity.User;
import com.example.admin.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
@CrossOrigin(origins = "http://localhost:8080")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     * 用户列表分页查看
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getUserPage")
    public Result<PageInfo<User>> getUserPAge(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<User> userList = userService.getUserPage();
        PageInfo<User> pageInfo = new PageInfo<>(userList);
        return Result.success(pageInfo);
    }

    /**
     * 根据id删除
     */





}
